package com.kk.factory.abstractfactory;


import java.util.Scanner;

/**
 * @author 王志强
 * @date 2021-12-10
 */
public class OrderPizza {
    private IFactory factory;

    public OrderPizza(IFactory factory) {
        this.factory = factory;
        AbstractPizza pizza;
        String type;


        while (true) {
            type = getType();
            pizza = factory.createPizza(type);

            if (pizza != null) {
                System.out.println("使用的是抽象工厂模式");
                pizza.prepare();
            }

        }
    }


    /**
     * 拿到用户输入的 pizza 类型
     */
    private String getType() {
        Scanner scanner = new Scanner(System.in);
        return scanner.nextLine();
    }

}
